
<?php 
	jimport('joomla.application.component.model');
	class kinh_doanhModelthong_tin_don_hang extends JModel
	{
        function lay_id_sp()
        {
            //echo "ss";die;
            $user = JFactory::getUser();
                    //dang nhap thanh cong lay duoc id -> lay id_a_b tu table bran_user, 
                    $sql = "select id_a_b from #__erp_agent_branch_user where id_user ='".$user->get('id')."' ";
                    $db = &JFactory::getDBO();
        		    $db->setQuery($sql);
        		    $id_a_b = $db->loadResult();
                    $_SESSION['id_a_b'] = $id_a_b; 	
                    
            $sql = "select ep.id_product,ep.name, ep.img, ept.id as id_type, ept.name as name_type, eabw.number_of, ep.price, cur.name as cur_name, cur.id as cur_id, cur.symbol, ui.name as ui_name, eab.id as id_a_b
                            from #__erp_product ep ,#__erp_product_type ept ,#__erp_agent_branch eab,#__erp_agent_branch_warehouse eabw ,  #__erp_financial_currency cur, #__erp_product_unit ui
                            where 
                            ep.id_type_product = ept.id and 
                            ep.id_product = eabw.id_product and
                            eab.id = eabw.id_a_b and
                            ep.id_currency = cur.id and
                            ui.id = ep.id_unit and
                            eab.id = '".$id_a_b."'   
                            order by ept.name  
                        ";
                        
            $db->setQuery($sql);
            //print_r($db->loadObjectList());die;
			return $db->loadObjectList();
        }
        	   
		
			
	}
?>